'use strict';
import Vue from 'vue';
import Mint from 'mint-ui';
import './static/vendor/mui/css/mui.css';
import 'mint-ui/lib/style.css';
import './static/css/global.css';
import VueRouter from 'vue-router';
import Axios from 'axios';
import App from './app.vue';
import Home from './components/home/home.vue';
import Member from './components/member/member.vue';
import Search from './components/search/search.vue';
import Shopcart from './components/shopcart/shopcart.vue';
import NewsList from './components/news/newslist.vue';
import NewsDetail from './components/news/newsdetail.vue';
import Moment from 'moment';
import NavBarVue from './components/common/navBar.vue';
import PhotoShare from './components/photo/photoshare.vue';
import VuePreview from 'vue-preview';
import Pinlun from './components/common/pinglun.vue';
import GoodsList from './components/goods/goodslist.vue';
import GoodsDetail from './components/goods/goodsdetail.vue';
import SwipeVue from './components/common/swipe.vue';
//import GoodsComment from './components/goods/goodspinlun.vue';
const GoodsComment = () => import('./components/goods/goodspinlun.vue');
const ConnectUs = () => import('./components/connectus/connectus.vue');
const BMap = () => import('./components/bmap/Map.vue');

Vue.use(VuePreview);

// alert(window.screen.height + ";" + window.screen.width)
Vue.use(VueRouter);
Vue.use(Mint);
// 默认配置
Vue.prototype.$axios = Axios;
Axios.defaults.baseURL = "http://192.0.0.153:8080/";
//拦截器
//loading效果
Axios.interceptors.request.use(function(config) {
	Mint.Indicator.open({
		text: 'Loading...',
		spinnerType: 'fading-circle'
	});
	return config;
});
Axios.interceptors.response.use(function(config) {
	Mint.Indicator.close();
	return config;
});

// 定义全局过滤器
Vue.filter('convertDate', function(value) {
	return Moment(value).format("YYYY-MM-DD");
})

//定义全局组件
Vue.component("navBarVue", NavBarVue);
Vue.component("pinLunVue", Pinlun);
Vue.component("swipeVue", SwipeVue);
Vue.component("GoodsComment", GoodsComment);
Vue.component("BMap", BMap);

let router = new VueRouter({
	linkActiveClass: 'mui-active', // 当前路由样式
	routes: [{
			path: '/',
			redirect: {
				name: 'home'
			}
		},
		{
			name: 'home',
			path: '/home',
			component: Home
		},
		{
			name: 'member',
			path: '/member',
			component: Member
		},
		{
			name: 'shopcart',
			path: '/shopcart',
			component: Shopcart
		},
		{
			name: 'search',
			path: '/search',
			component: Search
		},
		{
			name: 'news.list',
			path: '/news/list',
			component: NewsList
		},
		{
			name: 'news.detail',
			path: '/news/detail',
			component: NewsDetail
		},
		{
			name: 'photo.share',
			path: '/photo/share',
			component: PhotoShare
		},{
			name: 'goods.list',
			path: '/goods/list',
			component: GoodsList
		},{
			name: 'goods.detail',
			path: '/goods/detail',
			component: GoodsDetail
		},{
			name: 'goods.comment',
			path: '/goods/comment',
			component: GoodsComment
		},{
			name : 'connectus',
			path: '/connectus',
			component: ConnectUs
		}
	]
});

new Vue({
	el: '#app',
	router,
	render: c => c(App)
});